//
//  System.hpp
//  WiFiMACSim
//
//  Created by Christopher Kemsley on 3/31/12.
//  Copyright (c) 2012 iAppolopolis. All rights reserved.
//

#ifndef WiFiMACSim_System_hpp
#define WiFiMACSim_System_hpp

#include "Types.hpp"
#include "RunLoop.hpp"

SimNamespaceBegin


// for use in ostream
#define	SlotStamp		"<"<<(System::shared().currentSlot())<<"> "




class	System : private RunLoopSource
{
public:
	
	static System&		shared () ;
	
	
	
	// Equivalent of "currentTime"
	UInteger			currentSlot () ;
	
	
	
	
private:
	
	System () ;
	~System () ;
	
	virtual void	runFromRunLoop ( RunLoop & sender , RunLoop::Mode mode ) ;
	
	UInteger	mCurrentSlot ;
} ;





struct	SlotTimer
{
	SlotTimer () ;
	~SlotTimer () ;
	
	// if now=1 and slots=2, will fire at slot=4
	void	skipNext	( UInteger slots ) ;
	
	// if now=1 and slots=2, will fire at slot=3
	void	skip		( UInteger slots ) ;
	
	
	void	reset () ;
	bool	isTime () ;
	bool	isReset () ;
	
	
private:
	UInteger	mFireDate ;
} ;




SimNamespaceEnd
#endif
